package com.itany.springcloud.consumer.service;

import com.itany.springcloud.consumer.service.fallback.UserServiceFallback;
import com.itany.springcloud.springcloudcommon.entity.User;
import com.itany.springcloud.springcloudcommon.vo.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

@Service
//@FeignClient(value = "springcloud-nacos-provider",fallback = UserServiceFallback.class)
@FeignClient(value = "springcloud-nacos-gateway",fallback = UserServiceFallback.class)
public interface UserService {

    @GetMapping("/users")
    public ResponseResult findAll();

    @GetMapping("/users/{id}")
    public ResponseResult findById(@PathVariable("id") Integer id);

    @PostMapping("/users")
    public ResponseResult add(@RequestParam("username")  String username, @RequestParam("password") String password);

    @PostMapping("/users/add2")
    public ResponseResult add2(@RequestBody User user);

    @PostMapping("/users/add3")
    public ResponseResult add3(@SpringQueryMap User user);

    @DeleteMapping("/users/{id}")
    public ResponseResult remove(@PathVariable("id") Integer id);

    @PutMapping("/users")
    public ResponseResult modify(@RequestParam("id") Integer id,@RequestParam("username") String username,@RequestParam("password") String password);
}
